<template>
  <a :title="title" href="#">
    <svg class="icon" aria-hidden="true" @click="handleClick">
      <use :xlink:href="icon"></use>
    </svg>
  </a>
</template>

<script>
export default {
  name: "SvgIcon",
  props: {
    name: {
      type: String,
      default: "qunzu",
    },
    title: {
      type: String,
      default: "",
    },
  },
  computed: {
    icon() {
      return `#icon-${this.name}`
    },
  },
  data() {
    return {}
  },

  mounted() {},

  methods: {
    handleClick() {
      this.$emit("click")
    },
  },
}
</script>

<style lang="scss" scoped>
//图标相关
.icon {
  width: 1.5em;
  height: 1.5em;
  fill: currentColor;
  overflow: hidden;
  color: #fff;
}
svg {
  cursor: pointer;
}
a {
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
